package com.hytc.mymall.frgament;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hytc.mymall.base.BaseFragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by allkiss on 2016/12/9
 */

public class ConcessionsFragmemt extends BaseFragment
//        implements View.OnClickListener
{
//    private ConcessionsAdapter adapter;
//    private int datescope;
//    private ImageView iv_arrow;
//    private List<ConcessionsBean.Rows_Concessions> list;
//    private LinearLayout ll_nodata;
//    private ListView lv;
//    private int page;
//    private SelectPop pop;
//    private PullToRefreshListView ptrlv;
//    private String token;
//    private TextView tv_selection;
//    private TextView tv_yingrl;
//    private TextView tv_yirl;
//
//    public ConcessionsFragmemt() {
//        this.list = new ArrayList<ConcessionsBean.Rows_Concessions>();
//        this.datescope = 5;
//        this.page = 1;
//    }
//
//    static /* synthetic */ void access$7(final ConcessionsFragmemt concessionsFragmemt, final int page) {
//        concessionsFragmemt.page = page;
//    }
//
//    private void initData() {
//        this.token = ActivityManager.loginBean.auth.aukeyValue;
//        this.loadData(true, true);
//        this.adapter = new ConcessionsAdapter((Context) this.getActivity(), this.list);
//        this.lv.setAdapter((ListAdapter) this.adapter);
//    }
//
//    private void loadData(final boolean b, final boolean b2) {
//        final HashMap<String, String> hashMap = new HashMap<String, String>();
//        hashMap.put("token", this.token);
//        hashMap.put("inspiretype", new StringBuilder(String.valueOf(ActivityManager.loginBean.drivetype)).toString());
//        hashMap.put("page", new StringBuilder(String.valueOf(this.page)).toString());
//        hashMap.put("rows", "10");
//        OkHttpClientManager.postAsyn("http://www.51ydgy.com/merchantApp/dailySales", new StringPopCallBack(this.getActivity(), b) {
//            @Override
//            public void onResponse(final String s) {
//                ConcessionsBean concessionsBean;
//                while (true) {
//                    while (true) {
//                        try {
//                            concessionsBean = GsonUtils.json2Bean(s, ConcessionsBean.class);
//                            if (concessionsBean == null || !concessionsBean.code.equals("0")) {
//                                break;
//                            }
//                            if (b2) {
//                                if (concessionsBean.data.total.equals("0")) {
//                                    ConcessionsFragmemt.this.ll_nodata.setVisibility(View.VISIBLE);
//                                } else {
//                                    ConcessionsFragmemt.this.ll_nodata.setVisibility(View.GONE);
//                                }
//                                ConcessionsFragmemt.this.list.clear();
//                                ConcessionsFragmemt.this.list.addAll(concessionsBean.data.rows);
//                                ConcessionsFragmemt.this.tv_yingrl.setText((CharSequence) (String.valueOf(ConcessionsFragmemt.this.getResources().getString(R.string.wangergou)) + concessionsBean.data.returnamount));
//                                ConcessionsFragmemt.this.tv_yirl.setText((CharSequence) (String.valueOf(ConcessionsFragmemt.this.getResources().getString(R.string.wangergou)) + concessionsBean.data.alreadymoney));
//                                ConcessionsFragmemt.this.ptrlv.onPullDownRefreshComplete();
//                                if (Integer.parseInt(concessionsBean.data.total) < 10 * ConcessionsFragmemt.this.page) {
//                                    ConcessionsFragmemt.this.ptrlv.setHasMoreData(false);
//                                    ConcessionsFragmemt.this.ptrlv.setPullLoadEnabled(false);
//                                }
//                                ConcessionsFragmemt.this.adapter.notifyDataSetChanged();
//                                return;
//                            }
//                        } catch (Exception ex) {
//                            ex.printStackTrace();
//                            ConcessionsFragmemt.this.ll_nodata.setVisibility(View.VISIBLE);
//                            return;
//                        }
//                        ConcessionsFragmemt.this.list.addAll(concessionsBean.data.rows);
//                        ConcessionsFragmemt.this.ptrlv.onPullUpRefreshComplete();
//                        continue;
//                    }
//                }
////                ToastUtils.showToastWithImage(ConcessionsFragmemt.this.getActivity(), concessionsBean.msg, false);
//            }
//        }, hashMap);
//    }
//
//    private void setPullLoad() {
//        this.ptrlv.setPullLoadEnabled(true);
//        this.ptrlv.setPullRefreshEnabled(true);
//        this.ptrlv.setOnRefreshListener((PullToRefreshBase.OnRefreshListener<ListView>) new PullToRefreshBase.OnRefreshListener<ListView>() {
//            @Override
//            public void onPullDownToRefresh(final PullToRefreshBase<ListView> pullToRefreshBase) {
//                ConcessionsFragmemt.access$7(ConcessionsFragmemt.this, 1);
//                ConcessionsFragmemt.this.ptrlv.setPullLoadEnabled(true);
//                ConcessionsFragmemt.this.loadData(false, true);
//            }
//
//            @Override
//            public void onPullUpToRefresh(final PullToRefreshBase<ListView> pullToRefreshBase) {
//                final ConcessionsFragmemt this$0 = ConcessionsFragmemt.this;
//                ConcessionsFragmemt.access$7(this$0, 1 + this$0.page);
//                ConcessionsFragmemt.this.loadData(false, false);
//            }
//        });
//    }
//
    @Override
    public void initView(final View view) {
//        final TextView textView = this.$(view, 2131100411);
//        final RelativeLayout relativeLayout = this.$(view, 2131100413);
//        this.iv_arrow = this.$(view, 2131100417);
//        this.tv_selection = this.$(view, 2131100416);
//        this.tv_yingrl = this.$(view, 2131100077);
//        this.tv_yirl = this.$(view, 2131100078);
//        this.ll_nodata = this.$(view, 2131099755);
//        this.ptrlv = this.$(view, 2131100079);
//        (this.lv = this.ptrlv.getRefreshableView()).setDividerHeight(1);
//        textView.setText((CharSequence) this.getResources().getString(R.string.wangergou));
//        relativeLayout.setVisibility(View.GONE);
//        relativeLayout.setOnClickListener((View.OnClickListener) this);
    }
//
//    public void onClick(final View view) {
//        switch (view.getId()) {
//            default: {
//            }
//            case 2131100413: {
//                this.pop.showPop();
//            }
//        }
//    }
//
//    public View onCreateView(final LayoutInflater layoutInflater, final ViewGroup viewGroup, final Bundle bundle) {
//        return layoutInflater.inflate(R.layout.fragment_concessions, (ViewGroup) null);
//    }
//
//    @Override
//    public void onViewCreated(final View view, final Bundle bundle) {
//        super.onViewCreated(view, bundle);
//        this.setPullLoad();
//        this.initData();
//    }
}